﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Configurations;
using System.Xml.Serialization;

//报表序列化接口
namespace Pixysoft.Framework.Reports
{
    public interface IReportSetting
    {
        string ReportName { get;set;}

        int Width { get;set;}

        IReportLayout GetPageHeader();

        IReportLayout GetPageFooter();


        IReportRowSetting[] GetRowSettings();

        IReportRowSetting CreateRowSetting(ExpressionType type, string headername, string columnname);

        IReportRowSetting GetRowSetting(string settingCode);

        IReportRowSetting RemoveRowSetting(string settingCode);



        IReportColumnSetting[] GetColumnSettings();

        IReportColumnSetting CreateColumnSetting(ExpressionType type, string headername, string columnname);

        IReportColumnSetting GetColumnSetting(string settingCode);

        IReportColumnSetting RemoveColumnSetting(string settingCode);


        IReportCellSetting[] GetCellSettings();

        IReportCellSetting CreateCellSetting(FunctionType type, string expression, IReportColumnSetting columnSetting, IReportRowSetting rowSetting);

        IReportCellSetting GetCellSetting(IReportColumnSetting column, IReportRowSetting row);

        IReportCellSetting GetCellSetting(string columnSettingCode, string rowSettingCode);

        IReportCellSetting GetCellSetting(string settingCode);

        IReportCellSetting RemoveCellSetting(string settingCode);

        /// <summary>
        /// 当序列化之后 建立parent指针引用
        /// </summary>
        void Build();

        /// <summary>
        /// 当setting变动后，修正cell的设置
        /// </summary>
        void Refresh();
    }

    public interface IReportColumnSetting
    {
        string SettingCode { get;set;}

        int ColumnIndex { get;set;}

        /// <summary>
        /// 列配置类型
        /// </summary>
        ExpressionType ExpressionType { get;set; }

        /// <summary>
        /// 列标题
        /// </summary>
        string HeaderName { get;set; }

        /// <summary>
        /// 列配置的数据源
        /// </summary>
        string ColumnName { get;set; }


        IReportColumnSetting GetParent();

        /// <summary>
        /// 子配置节点
        /// </summary>
        IReportColumnSetting[] GetChildrenSettings();

        IReportColumnSetting CreateChildrenSetting(ExpressionType type, string headername, string columnname);

        IReportColumnSetting RemoveChildSetting(string settingCode);

        IReportColumnSetting GetChildren(string settingCode);

        void Build();
    }

    public interface IReportRowSetting
    {
        string SettingCode { get;  set;}

        int RowIndex { get;set;}

        /// <summary>
        /// 列配置类型
        /// </summary>
        ExpressionType ExpressionType { get;set; }

        /// <summary>
        /// 列标题
        /// </summary>
        string HeaderName { get;set; }

        /// <summary>
        /// 列配置的数据源
        /// </summary>
        string ColumnName { get;set; }


        IReportRowSetting GetParent();

        void SetParent(IReportRowSetting setting);

        /// <summary>
        /// 子配置节点
        /// </summary>
        IReportRowSetting[] GetChildrenSettings();

        IReportRowSetting CreateChildrenSetting(ExpressionType type, string headername, string rowname);

        IReportRowSetting RemoveChildSetting(string settingCode);

        IReportRowSetting GetChildren(string settingCode);

        void Build();
    }

    public interface IReportCellSetting
    {
        string SettingCode { get;set;}

        /// <summary>
        /// 单元格类型
        /// </summary>
        FunctionType FunctionType { get;set; }

        /// <summary>
        /// 单元格表达式
        /// </summary>
        string FunctionExpression { get;set; }

        string RowSettingCode { get;set;}

        string ColumnSettingCode { get;set;}
    }


}
